## VARYING-INTERCEPT MODEL WITH GROUP MEANS AT THE SECOND LEVEL

model {
	for (i in 1:N) {                     # N OBSERVATIONS
		y[i] ~ dnorm (yhat[i], tau.y)	    
	    yhat[i] <- inprod(B[], X.1[i,]) + d[country[i]]
	}
        
    # PRIOR OF PRECISION PARAMETER TAU
    tau.y ~ dgamma (0.01, 0.01)   # dgamma (r, mu), WHERE r IS THE SHAPE AND mu IS THE RATE PARAMETER      
    sigma.y <- 1/sqrt(tau.y)     

    # UNMODELED COEFFICIENTS
    for (k in 1:M.1) {    	
    	B[k] ~ dnorm (0, 0.01)
    }	

    # VARYING COEFFICIENTS ARE MODELED BY GROUP-LEVEL PREDICTORS
    for (j in 1:J){
    	d[j] ~ dnorm (d.hat[j], tau.d)
        d.hat[j] <- inprod(G[], Z.1[j,])
    }
    tau.d ~ dgamma (0.01, 0.01) 
    sigma.d <- 1/sqrt(tau.d)
    
    for (l in 1:L) {
        G[l] ~ dnorm (0, 0.01)  
    }    	       

}